<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
      <style>
        .content {
            color: red;
        }
      </style>
<body>
    <div class="box">
    </div>
    
</body>
</html>
<script>
        //封装ajax函数
        function ajax( method, url, cb ){
            //1.创建请求对象
            var xhr = new XMLHttpRequest()

            //2.配置请求对象
            xhr.open(method,url);

            //3.设置回调函数
            xhr.onreadystatechange = function(){
                if( xhr.readyState == 4 ){
                    cb( JSON.parse(xhr.responseText) )
                }
            }
            //4.发送请求
            xhr.send();
        }
        ajax('get','./news.json',function(data){   
            // console.log(data.list);
            var str=data.list.map((item)=>{
                return `<div class="content">${item.new}</div>`
            }).join('')
            document.querySelector('.box').innerHTML=str
        })
</script>